<!----------------引入头部文件-------------------->
<include file="Common/title" />

<script type="text/javascript">
    mui.init()
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">个人中心</h1>
</header>
<div class="mui-content">
    <div class="mui-card">
    <ul class="mui-table-view">

        <li class="mui-table-view-divider">我的消息</li>
        <?php foreach($info as $k=>$v){
            if($receiver_id == $v['id']){
                $style = 'style="color:red"';
            }else{
                $style = '';
            }
        ?>
        <li class="mui-table-view-cell" <?php echo $style;?> onclick="chat(this);" receiver_id="<?php echo $v['id']; ?>">
            与<?php echo $v['name']; ?>的聊天消息
            <?php if($v['num'] > 0): ?>
            <span class="mui-badge mui-badge-danger">
               <?php echo $v['num'];?>
            </span>
            <?php endif; ?>
        </li>
        <?php } ?>

    </ul>
</div>
</div>
<include file="Common/nav"/>
</body>
</html>
<script>
    var userid = '{$userid}';  //当前用户ID
    var type = '{$type}';  //当前用户类型
    function chat(a){
       // alert(userid);return;
        var receiver_id = $(a).attr('receiver_id');
        //alert(receiver_id);return;
        if(type == 'kefu'){

            location.href = '__CONTROLLER__/kefu_chat/userid/'+userid+'/receiver_id/'+receiver_id;
        }else if(type == 'yonghu'){
            location.href = '/Home/Chat/chat_window/userid/'+userid+'/kefuid/'+receiver_id;

        }

    }
    mui.ready(function(){
        //把当前用户的聊天状态改为退出状态
        url = '/Home/Online/update_user_online/userid/'+userid+'/user_type/'+type;
        $.get(url,function(e){
            //alert(e);
        })
    })
</script>